<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
  </head>
  <body>
    我的ID：
    <h2 id="myid"></h2>
    我的名字：
    <h1 id="myname"></h1>
    我的头像：<img id="myimg" src="" width="100" height="100" alt="" />
    <p></p>
    性别：
    <h2 id="sex"></h2>
    注册时间：
    <h2 id="reg_time"></h2>
    <a href="userlist.html">用户列表</a>
    <a href="lyb.html">留言板</a>
  </body>
  <script>
    ;(function () {
      $.ajax({
        url: '/lyb/userinfo.php',
        type: 'get',
        dataType: 'json',
        success: function (res) {
          console.log(res)
          if (res.code == 200 && res.msg == 'success') {
            $('#myid').text(res.data.id)
            $('#myname').text(res.data.username)
            $('#myimg').attr('src', res.data.avator)
            let sex = res.data.sex == 1 ? '男' : '女'
            $('#sex').text(sex)
            $('#reg_time').text(res.data.created_at)
          }
        },
      })
    })()
  </script>
</html>
